<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>详情页</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" href="../static/css/typo.css">
    <link rel="stylesheet" href="../static/css/animate.css">
    <link rel="stylesheet" href="../static/lib/prism/prism.css">
    <link rel="stylesheet" href="../static/lib/tocbot/tocbot.css">
    <link rel="stylesheet" href="../static/css/me.css">
</head>
<body>
<!--导航栏-->
<nav th:fragment="menu(n)" class="ui inverted attached segment m-padded-tb-mini m-shadow-small" >
    <div class="ui container">
        <div class="ui inverted secondary stackable menu">
            <h2 class="ui teal header item">Disney</h2>
            <a href="#" th:href="@{/}" class="m-item item m-mobile-hide " th:classappend="${n==1} ? 'active'"><i class="mini home icon"></i>首页</a>
            <a href="#" th:href="@{/types/-1}" class="m-item item m-mobile-hide" th:classappend="${n==2} ? 'active'"><i class="mini idea icon"></i>分类</a>
            <a href="#" th:href="@{/tags/-1}" class="m-item item m-mobile-hide" th:classappend="${n==3} ? 'active'"><i class="mini tags icon"></i>标签</a>
            <a href="#" th:href="@{/archive}" class="m-item item m-mobile-hide" th:classappend="${n==4} ? 'active'"><i class="mini clone icon"></i>归档</a>
            <a href="#" th:href="@{/about}" class="m-item item m-mobile-hide" th:classappend="${n==5} ? 'active'"><i class="mini info icon"></i>关于我</a>
            <div class="right m-item item m-mobile-hide">
                <form name="search" action="#" th:action="@{/search}" method="post" target="_blank">
                    <div class="ui icon inverted transparent input m-margin-tb-tiny">
                        <input type="text" name="query" placeholder="Search...." th:value="${query}">
                        <i onclick="document.forms['search'].submit()" class="search link icon"></i>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show">
        <i class="sidebar icon"></i>
    </a>
</nav>


<!--中间内容-->
<div class="m-container-small m-padded-tb-large">
    <div class="ui container">
        <!--头部-->
        <div class="ui top attached segment">
            <!--左侧-->
            <div class="ui horizontal link list">
                <div class="item">
                    <!--头像-->
                    <img src="https://picsum.photos/100/100?image=1010" th:src="@{${blog.user.avatar}}" alt="" class="ui avatar image">
                    <!--名称-->
                    <div class="content">
                        <a href="#" class="header" th:text="${blog.user.nickname}" >Disney</a>
                    </div>
                </div>
                <!--发文时间-->
                <div class="item">
                    <i class="calendar icon"></i><span th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd')}" >2021-12</span>
                </div>
                <!--浏览次数和眼睛-->
                <div class="item">
                    <i class="eye icon"></i><span th:text="${blog.views}" >2032</span>
                </div>
            </div>

        </div>
        <!--图片区域-->
        <div class="ui attached segment"><!--attached 将div之间连接没有间隙-->
            <img src="https://picsum.photos/800/450?image=1025" th:src="@{${blog.firstPicture}}" alt="" class="ui fluid rounded image"><!--rounded 圆角-->
        </div>

        <!--主要内容-->
        <div class="ui attached padded segment">
            <!--原创按钮-->
            <div class="ui right aligned basic segment">
                <div class="ui orange basic label" th:text="${blog.flag}" >原创</div>
            </div>

            <!--内容-->
            <h2 class="ui center aligned header" th:text="${blog.title}">MickeyMouse</h2>
            <br>

            <div id="content" class="m-padded-lr-responsive m-padded-tb-large">
                米老鼠(米奇)这一形象考验着"好人难觅"的说法。<br>
                米奇乐观豁达，拥有男孩子的热心天性，使他成为一个真正的赢家。<br>
                他有孩子般的友好真诚，健康的价值观和敢想敢为的精神，这更是让米奇人见人爱。<br>
                他不装腔作势，谦逊朴素，虽然声名远播，有很多辉煌的成就，在大家心目中建立了一个优秀的形象，但他却谦恭的做着一个普通人。<br>
                米奇积极向上，诚实正直，敢想敢为的良好品质让他成为我们都想拥有的好朋友，也成为我们效仿的好榜样。<br>
            </div>

            <!--标签-->
            <div class="m-padded-lr">
                <div class="ui basic teal left pointing label" th:each="tag : ${blog.tags}">方法论</div>
            </div>

            <!--赞赏-->
            <div class="ui center aligned basic segment">
                <button id="payButton" class="ui orange basic circular button">赞赏</button>
            </div>
            <!--二维码-->
            <div class="ui payQR flowing popup transition hidden">
                <div class="ui orange basic label">
                    <div class="ui images" style="font-size: inherit !important;">
                        <div class="image" >
                            <img src="./static/images/dashang.png" th:src="@{/images/dashang.png}" alt="" class="ui rounded bordered image" style="width:120px ">
                            <div>支付宝</div>
                        </div>
                        <div class="image">
                            <img src="./static/images/dashang.png" th:src="@{/images/dashang.png}" alt="" class="ui rounded bordered image" style="width:120px ">
                            <div>微信</div>
                        </div>
                    </div>
                </div>
            </div>


        </div>

        <!--博客信息-->
        <div class="ui attached positive message">
            <div class="ui middle aligned grid">
                <!--信息说明-->
                <div class="eleven wide column">
                    <ul class="list">
                        <li>作者：<span th:text="${blog.user.nickname}" >beauty</span><a href="#" th:href="@{/about}" target="_blank">（联系作者）</a> </li>
                        <li>发表时间：2021-12</li>
                        <li>版权声明：自由转载-非商用-非衍生-保持署名（创意恭喜</li>
                        <li>作者:beauty （联系作者）</li>
                    </ul>
                </div>
                <!--二维码-->
                <div class="five wide column">
                    <img src="./static/images/erweima.png" th:src="@{/images/erweima.png}" alt="" class="ui right floated rounded image" style="width: 110px">
                </div>
            </div>

        </div>
        <!--留言区域-->
        <div class="ui bottom attached segment">
            <!--留言区域列表-->
            <div id="comment-container" class="ui teal segment">
                <div th:fragment="commentList">
                <div  class="ui threaded comments" style="max-width: 100%">
                    <h3 class="ui dividing header">评论</h3>
                    <div class="comment" th:each="comment : ${comments}">
                        <a class="avatar">
                            <img src="https://picsum.photos/100/100?image=111" th:src="@{${comment.avatar}}">
                        </a>
                        <div class="content">
                            <a class="author" th:text="${comment.nickname}">Matt</a>
                            <div class="metadata">
                                <span class="date" th:text="${#dates.format(comment.creatTime,'yyyy-MM-dd HH:mm')}">Today at 5:42PM</span>
                            </div>
                            <div class="text" th:text="${comment.content}">
                                How artistic!
                            </div>
                            <div class="actions">
                                <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${comment.id},data-commentnickname=${comment.nickname}" onclick="reply(this)">回复</a>
                            </div>
                        </div>
                       <!--评论子集-->
                    <div class="comments" th:if="${#arrays.length(comment.replyComments)}>0">
                        <div class="comment" th:each="reply : ${comment.replyComments}">
                        <a class="avatar">
                            <img src="https://picsum.photos/100/100?image=1079">
                        </a>
                        <div class="content">
                            <a class="author">
                               <span th:text="${reply.nickname}">xiao</span><span th:text="|@ ${reply.parentComment.nickname} |" class="m-teal">@ 维尼</span>
                            </a>
                            <div class="metadata">
                                <span class="date" th:text="${#dates.format(reply.creatTime,'yyyy-MM-dd HH:mm')}">Yesterday at 12:30AM</span>
                            </div>
                            <div class="text" th:text="${reply.content}">
                                <p>This has been very useful for my research. Thanks as well!</p>
                            </div>
                            <div class="actions">
                                <a class="reply" data-commentid="1" data-commentnickname="Matt" th:attr="data-commentid=${reply.id},data-commentnickname=${reply.nickname}" onclick="reply(this)">回复</a>
                            </div>
                        </div>
                        </div>
                    </div>
                    </div>


                        <div class="comments">
                            <div class="comment">
                                <a class="avatar">
                                    <img src="https://picsum.photos/100/100?image=1071">
                                </a>
                                <div class="content">
                                    <a class="author">Jenny Hess</a>
                                    <div class="metadata">
                                        <span class="date">Just now</span>
                                    </div>
                                    <div class="text">
                                        Elliot you are always so right :)
                                    </div>
                                    <div class="actions">
                                        <a class="reply">回复</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="comment">
                        <a class="avatar">
                            <img src="https://picsum.photos/100/100?image=1062">
                        </a>
                        <div class="content">
                            <a class="author">Joe Henderson</a>
                            <div class="metadata">
                                <span class="date">5 days ago</span>
                            </div>
                            <div class="text">
                                Dude, this is awesome. Thanks so much
                            </div>
                            <div class="actions">
                                <a class="reply">回复</a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            </div>
        </div>
            <!--提交留言列表区域-->
            <div id="comment-form" class="ui form">
                <input type="hidden" name="blog.id" th:value="${blog.id}">
                <input type="hidden" name="parentComment.id" VALUE="-1">
                <div class="field">
                    <!--第一个输入框-->
                    <textarea name="content" placeholder="请输入评论信息……"></textarea>
                </div>
                <!--用户名以及邮箱输入框-->
                <div class="fields">
                    <div class="field m-mobile-wide m-margin-bottom-small">
                        <div class="ui left icon input">
                            <i class="user icon"></i>
                            <input type="text" name="nickname" placeholder="姓名" th:value="${session.user}!=null ? ${session.user.nickname}">
                        </div>
                    </div>
                    <div class="field m-mobile-wide m-margin-bottom-small">
                        <div class="ui left icon input">
                            <i class="mail icon"></i>
                            <input type="text" name="email" placeholder="邮箱" th:value="${session.user} !=null ? ${session.user.email}">
                        </div>
                    </div>
                    <!--按钮-->
                    <div class="field m-margin-bottom-small m-mobile-wide">
                        <button id="commentpost-btn" type="button" class="ui teal button m-mobile-wide">
                            <i class="edit icon"></i>发布
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>




<!--底部-->
<footer class="ui inverted vertical segment m-padded-tb-massive">
    <div class="ui center aligned container"><!--center aligned 居中-->
        <div class="ui inverted divided stackable grid"><!--grid会将div分为16份布局   inverted divided模块之间的线条显示-->
            <!--第一板块-->
            <div class="three wide column">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="./static/images/erweima.png" class="ui rounded image" alt="" style="width:100px">
                    </div>
                </div>
            </div>
            <!--第二板块-->
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">最新博客</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">用户故事（User Story）</a>
                    <a href="#" class="item">关于课余练习的清单</a>
                    <a href="#" class="item">成功要趁早</a>
                </div>
            </div>
            <!--第三板块-->
            <div class="three wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">联系我</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item">Email:Everyone@162.com</a>
                    <a href="#" class="item">QQ:123456789</a>
                </div>
            </div>

            <!--第四板块-->
            <div class="seven wide column">
                <h4 class="ui inverted header m-text-thin m-text-spaced ">Blog</h4>
                <p class="m-text-thin m-text-spaced m-opacity-mini ">这是我的个人博客、会分享关于编程、协作、思考相关的任何内容，希望可以给来到这儿的人有所帮助……</p>
            </div>
        </div>

        <!--第五板块-->
        <div class="ui inverted section divider"></div>
        <p class="m-text-thin m-text-spaced m-opacity-mini">Copyright @2021 Designed by zzz</p >
    </div>


</footer>


<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.10/semantic.min.js"></script>
<script>
    $('.menu.toggle').click(function (){
        $('.m-item').toggleClass('m-mobile-hide');
    });
    /*二维码事件*/
    $('#payButton').popup({
        popup :$('.payQR.popup'),
        on :'click',
        position: 'button center'
    })
    //评论表单验证
    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'content',
                rules: [{
                    type: 'empty',
                    prompt: '请输入评论内容'
                }
                ]
            },
            content: {
                identifier: 'nickname',
                rules: [{
                    type: 'empty',
                    prompt: '请输入你的大名'
                }]
            },
            type: {
                identifier: 'email',
                rules: [{
                    type: 'email',
                    prompt: '请填写正确的邮箱地址'
                }]
            }
        }
    });

    $(function (){
        $("#comment-container").load("comments/6");
    })

    $('#commentpost-btn').click( function() {
        var boo=$('.ui.form').form('validate form');
        if(boo) {
            console.log('校验成功');
        }else {
            console.log('校验失败');
        }
    });

//    发送请求
    function postData(){
        $("#comment-container").load("", {
            "parentComment.id": $("[name='parentComment.id']").val(),
            "blog.id": $("[name='blog.id']").val(),
            "nickname": $("[name='nickname']").val(),
            "email": $("[name='email']").val(),
            "content": $("[name='content']").val()
        },function (responseTxt,statusTxt,xhr){
            $(window).scrollTo($('#comment-container'),500);
            clearContent();
        });
    }

    function clearContent(){
        $("[name='content']").val('');
        $("[name='parentComment.id']").val('-1');
    }

    function reply(obj){
        var commentId = $(obj).data('commentid');
        var commentNickname = $(obj).data('commentnickname');
        $("[name='content']").attr("placeholder","@"+commentNickname).focus();
        $("[name='parentComment.id']").val(commentId);
        $(window).scrollTo($('#comment-form'),500);
        clearContent();
    }

    function clearContent(){
        $("[name='content']").val('');
        $("[name='parentComment.id']").val(-1);
        $("[name='content']").attr("placeholder", "请输入评论信息");
    }
</script>
</body>
</html>
